

users = {'user1': '12345', 'user2': '67890', 'user3': '98765'}
books_in=['活着','平凡的世界','三体','百年孤独','小王子']
books_out= ['人间失格']
# 用户
while True:
    user_name = input("请输入用户名：")
    if user_name in users:
        break
    else:
        print('用户名不正确请重新输入：')
while True:
    user_key = input("请输入密码:")
    if users[user_name] == user_key:
        while True:
            print("登录成功")
            print("1修改密码 ")
            print("2.借书")
            print("3.还书")
            choice=input("请输入你的选择：")
            if choice == '1':
                new_key = input("请输入新密码：")
                users[user_name] = new_key
                print("修改成功")
                print(users)
            if choice == '2':
                print(f"图书管有的书籍：{books_in}")
                borrow_book= input("请输入你要借的书籍：")
                if borrow_book in books_in:
                    books_in.remove(borrow_book)
                    books_out.append(borrow_book)
                    print('借书成功')
                    print(books_out)
                    print(books_in)
                else:
                    print('图书馆没有你要借的书籍')
            if choice == '3':
                print(f"当前借出的书籍有：{books_out}")
                return_book=input("请输入你要还的书籍：")
                if return_book in books_out:
                    books_out.remove(return_book)
                    books_in.append(return_book)
                    print('还书成功')
                    print(books_in)
                    print(books_out)
                else:
                    print("请正确输入你要归还的书籍/已归还")



    else:
        print("登录失败,请重新登录")



